# -*- coding: utf-8 -*-
# coding: UTF-8
import scrapy
from tutorial.items import SelectorItem
from scrapy.selector import Selector


class SelectorSpider(scrapy.Spider):
    name = 'selector'
    allowed_domains = ["scrapy.org"]
    start_urls = [
        'https://doc.scrapy.org/en/latest/_static/selectors-sample1.html',
    ]

    def parse(self, response):
        sel = Selector(response)

        item = SelectorItem()
        item['url'] = sel.url
        item['name'] = sel.xpath('//title/text()').extract()
        item['itmes'] = sel.xpath('//a[contains(@href, "image")]').extract()
        yield item
